<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>登录认证授权组件 | SPEED 团队企业级中台组件</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="$withBase(&#39;/avatar.png&#39;)">
    <meta name="description" content="">
    
    <link rel="preload" href="/assets/css/0.styles.4a390c75.css" as="style"><link rel="preload" href="/assets/js/app.9e59f384.js" as="script"><link rel="preload" href="/assets/js/2.61252cf6.js" as="script"><link rel="preload" href="/assets/js/10.47abf4f2.js" as="script"><link rel="prefetch" href="/assets/js/11.f25fa446.js"><link rel="prefetch" href="/assets/js/12.b817a6b9.js"><link rel="prefetch" href="/assets/js/13.a9ff20a6.js"><link rel="prefetch" href="/assets/js/14.5f5c406e.js"><link rel="prefetch" href="/assets/js/3.a4b7a9d2.js"><link rel="prefetch" href="/assets/js/4.8bbc0415.js"><link rel="prefetch" href="/assets/js/5.64a3d90d.js"><link rel="prefetch" href="/assets/js/6.65875694.js"><link rel="prefetch" href="/assets/js/7.c347ceab.js"><link rel="prefetch" href="/assets/js/8.07cb2ef7.js"><link rel="prefetch" href="/assets/js/9.be610aef.js">
    <link rel="stylesheet" href="/assets/css/0.styles.4a390c75.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/avatar.png" alt="SPEED 团队企业级中台组件" class="logo"> <span class="site-name can-hide">SPEED 团队企业级中台组件</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="业务中台" class="dropdown-title"><span class="title">业务中台</span> <span class="arrow down"></span></button> <button type="button" aria-label="业务中台" class="mobile-dropdown-title"><span class="title">业务中台</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/业务中台组件/登录认证授权组件.html" class="nav-link">
  登录认证授权组件
</a></li><li class="dropdown-item"><!----> <a href="/业务中台组件/数据脱敏组件.html" class="nav-link">
  数据脱敏组件
</a></li><li class="dropdown-item"><!----> <a href="/业务中台组件/OBS 对象存储组件.html" class="nav-link">
  OBS 对象存储组件
</a></li><li class="dropdown-item"><!----> <a href="/业务中台组件/邮件发送组件.html" class="nav-link">
  邮件发送组件
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据中台" class="dropdown-title"><span class="title">数据中台</span> <span class="arrow down"></span></button> <button type="button" aria-label="数据中台" class="mobile-dropdown-title"><span class="title">数据中台</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/数据中台组件/钉钉告警组件.html" class="nav-link">
  钉钉告警组件
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="业务中台" class="dropdown-title"><span class="title">业务中台</span> <span class="arrow down"></span></button> <button type="button" aria-label="业务中台" class="mobile-dropdown-title"><span class="title">业务中台</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/业务中台组件/登录认证授权组件.html" class="nav-link">
  登录认证授权组件
</a></li><li class="dropdown-item"><!----> <a href="/业务中台组件/数据脱敏组件.html" class="nav-link">
  数据脱敏组件
</a></li><li class="dropdown-item"><!----> <a href="/业务中台组件/OBS 对象存储组件.html" class="nav-link">
  OBS 对象存储组件
</a></li><li class="dropdown-item"><!----> <a href="/业务中台组件/邮件发送组件.html" class="nav-link">
  邮件发送组件
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据中台" class="dropdown-title"><span class="title">数据中台</span> <span class="arrow down"></span></button> <button type="button" aria-label="数据中台" class="mobile-dropdown-title"><span class="title">数据中台</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/数据中台组件/钉钉告警组件.html" class="nav-link">
  钉钉告警组件
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>业务中台</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/业务中台组件/登录认证授权组件.html" class="active sidebar-link">登录认证授权组件</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/业务中台组件/登录认证授权组件.html#_1-引入依赖" class="sidebar-link">1.引入依赖</a></li><li class="sidebar-sub-header"><a href="/业务中台组件/登录认证授权组件.html#_2-配置数据源" class="sidebar-link">2.配置数据源</a></li><li class="sidebar-sub-header"><a href="/业务中台组件/登录认证授权组件.html#_3-启动类配置包扫描路径" class="sidebar-link">3.启动类配置包扫描路径</a></li><li class="sidebar-sub-header"><a href="/业务中台组件/登录认证授权组件.html#_4-数据库脚本导入" class="sidebar-link">4.数据库脚本导入</a></li><li class="sidebar-sub-header"><a href="/业务中台组件/登录认证授权组件.html#_5-启动项目后访问接口" class="sidebar-link">5.启动项目后访问接口</a></li></ul></li><li><a href="/业务中台组件/数据脱敏组件.html" class="sidebar-link">数据脱敏组件</a></li><li><a href="/业务中台组件/OBS 对象存储组件.html" class="sidebar-link">OBS 对象存储组件</a></li><li><a href="/业务中台组件/邮件发送组件.html" class="sidebar-link">邮件发送组件</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>数据中台</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/数据中台组件/钉钉告警组件.html" class="sidebar-link">钉钉告警组件</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="登录认证授权组件"><a href="#登录认证授权组件" class="header-anchor">#</a> 登录认证授权组件</h1> <h2 id="_1-引入依赖"><a href="#_1-引入依赖" class="header-anchor">#</a> 1.引入依赖</h2> <div class="language-ruby extra-class"><pre class="language-ruby"><code>        <span class="token operator">&lt;</span>dependency<span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span>groupId<span class="token operator">&gt;</span>com<span class="token punctuation">.</span>tlgen<span class="token operator">&lt;</span><span class="token operator">/</span>groupId<span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span>artifactId<span class="token operator">&gt;</span><span class="token constant">SPEED</span><span class="token operator">-</span>auth<span class="token operator">-</span>login<span class="token operator">-</span>starter<span class="token operator">&lt;</span><span class="token operator">/</span>artifactId<span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span>version<span class="token operator">&gt;</span><span class="token number">2022.5</span><span class="token number">.19</span><span class="token operator">&lt;</span><span class="token operator">/</span>version<span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span><span class="token operator">/</span>dependency<span class="token operator">&gt;</span>
</code></pre></div><h2 id="_2-配置数据源"><a href="#_2-配置数据源" class="header-anchor">#</a> 2.配置数据源</h2> <div class="custom-block tip"><p class="custom-block-title">连接配置</p> <ol><li><p>数据库连接配置</p></li> <li><p>Redis 连接配置</p></li></ol></div> <div class="language-ruby extra-class"><pre class="language-ruby"><code>server<span class="token operator">:</span>
  <span class="token symbol">port</span><span class="token operator">:</span> <span class="token number">2022</span>
<span class="token symbol">spring</span><span class="token operator">:</span>
  <span class="token symbol">datasource</span><span class="token operator">:</span>
    driver<span class="token operator">-</span><span class="token keyword">class</span><span class="token operator">-</span>name<span class="token operator">:</span> com<span class="token punctuation">.</span>mysql<span class="token punctuation">.</span>cj<span class="token punctuation">.</span>jdbc<span class="token punctuation">.</span>Driver
    <span class="token symbol">url</span><span class="token operator">:</span> jdbc<span class="token symbol">:mysql</span><span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>localhost<span class="token operator">:</span><span class="token number">3306</span><span class="token operator">/</span>sample<span class="token operator">?</span>useUnicode<span class="token operator">=</span><span class="token boolean">true</span><span class="token operator">&amp;</span>useJDBCCompliantTimezoneShift<span class="token operator">=</span><span class="token boolean">true</span><span class="token operator">&amp;</span>useLegacyDatetimeCode<span class="token operator">=</span><span class="token boolean">false</span><span class="token operator">&amp;</span>serverTimezone<span class="token operator">=</span><span class="token constant">UTC</span>
    <span class="token symbol">username</span><span class="token operator">:</span> root
    <span class="token symbol">password</span><span class="token operator">:</span> <span class="token number">1234</span>

  <span class="token comment"># redis 配置</span>
  <span class="token symbol">redis</span><span class="token operator">:</span>
    <span class="token comment"># 地址</span>
    <span class="token symbol">host</span><span class="token operator">:</span> <span class="token number">127.0</span><span class="token number">.0</span><span class="token number">.1</span>
    <span class="token comment"># 端口，默认为6379</span>
    <span class="token symbol">port</span><span class="token operator">:</span> <span class="token number">6379</span>
    <span class="token comment"># 密码</span>
    <span class="token symbol">password</span><span class="token operator">:</span>

<span class="token comment"># token配置</span>
<span class="token symbol">token</span><span class="token operator">:</span>
  <span class="token comment"># 令牌自定义标识</span>
  <span class="token symbol">header</span><span class="token operator">:</span> Authorization
  <span class="token comment"># 令牌密钥</span>
  <span class="token symbol">secret</span><span class="token operator">:</span> abcdefghijklmnopqrstuvwxyz
  <span class="token comment"># 令牌有效期（默认30分钟）</span>
  <span class="token symbol">expireTime</span><span class="token operator">:</span> <span class="token number">30</span>
</code></pre></div><h2 id="_3-启动类配置包扫描路径"><a href="#_3-启动类配置包扫描路径" class="header-anchor">#</a> 3.启动类配置包扫描路径</h2> <div class="language-ruby extra-class"><pre class="language-ruby"><code><span class="token variable">@MapperScan</span><span class="token punctuation">(</span><span class="token string-literal"><span class="token string">&quot;com.tlgen.mapper&quot;</span></span><span class="token punctuation">)</span>
</code></pre></div><h2 id="_4-数据库脚本导入"><a href="#_4-数据库脚本导入" class="header-anchor">#</a> 4.数据库脚本导入</h2> <div class="language-ruby extra-class"><pre class="language-ruby"><code><span class="token number">11111</span>
</code></pre></div><h2 id="_5-启动项目后访问接口"><a href="#_5-启动项目后访问接口" class="header-anchor">#</a> 5.启动项目后访问接口</h2> <div class="custom-block tip"><p class="custom-block-title">验证码接口</p> <p>【GET】http://localhost:2022/auth/captchaImage</p></div> <div class="language-ruby extra-class"><pre class="language-ruby"><code>【<span class="token constant">GET</span>】http<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>localhost<span class="token operator">:</span><span class="token number">2022</span><span class="token operator">/</span>auth<span class="token operator">/</span>captchaImage

返回

<span class="token punctuation">{</span>
    <span class="token string-literal"><span class="token string">&quot;code&quot;</span></span><span class="token operator">:</span> <span class="token string-literal"><span class="token string">'ABCD'</span></span><span class="token punctuation">,</span>
    <span class="token string-literal"><span class="token string">&quot;uuid&quot;</span></span><span class="token operator">:</span> <span class="token string-literal"><span class="token string">&quot;xxxxxx&quot;</span></span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</code></pre></div><div class="custom-block tip"><p class="custom-block-title">登录接口</p> <p>【POST】http://localhost:2022/auth/login</p></div> <div class="language-ruby extra-class"><pre class="language-ruby"><code>【<span class="token constant">POST</span>】http<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>localhost<span class="token operator">:</span><span class="token number">2022</span><span class="token operator">/</span>auth<span class="token operator">/</span>login

<span class="token punctuation">{</span>
    <span class="token string-literal"><span class="token string">&quot;username&quot;</span></span><span class="token operator">:</span> <span class="token string-literal"><span class="token string">&quot;叶静&quot;</span></span><span class="token punctuation">,</span>
    <span class="token string-literal"><span class="token string">&quot;password&quot;</span></span><span class="token operator">:</span> <span class="token string-literal"><span class="token string">&quot;1234&quot;</span></span><span class="token punctuation">,</span>
    <span class="token string-literal"><span class="token string">&quot;code&quot;</span></span><span class="token operator">:</span> <span class="token string-literal"><span class="token string">&quot;ABCD&quot;</span></span><span class="token punctuation">,</span>
    <span class="token string-literal"><span class="token string">&quot;uuid&quot;</span></span><span class="token operator">:</span> <span class="token string-literal"><span class="token string">&quot;xxxxxx&quot;</span></span>
<span class="token punctuation">}</span>

返回

<span class="token punctuation">{</span>
    <span class="token string-literal"><span class="token string">&quot;msg&quot;</span></span><span class="token operator">:</span> <span class="token string-literal"><span class="token string">&quot;操作成功&quot;</span></span><span class="token punctuation">,</span>
    <span class="token string-literal"><span class="token string">&quot;code&quot;</span></span><span class="token operator">:</span> <span class="token number">200</span><span class="token punctuation">,</span>
    <span class="token string-literal"><span class="token string">&quot;token&quot;</span></span><span class="token operator">:</span> <span class="token string-literal"><span class="token string">&quot;eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImU3Y2NlYjFkLTY1YTAtNGNkYy1hN2M3LWU5YzNhNTYzNzFjZSJ9.8cnKJIQsXEERTVvZtB6_eAGZrHmzzy3LVEJWjBGKr7X1mPm_Qhh09Y6FX_QYgeL2i8Wcf3izjMYFRt1V5j0H3w&quot;</span></span>
<span class="token punctuation">}</span>
</code></pre></div></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><!----> <span class="next"><a href="/业务中台组件/数据脱敏组件.html">
        数据脱敏组件
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.9e59f384.js" defer></script><script src="/assets/js/2.61252cf6.js" defer></script><script src="/assets/js/10.47abf4f2.js" defer></script>
  </body>
</html>
